﻿using FBroSharp;
using FBroSharp.Const;
using FBroSharp.DataType;
using FBroSharp.VIP;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VIP指纹测试
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //获取当前设备机器码，机器码是给作者生成VIP注册码用的
            //Console.WriteLine(FBroSharpVIPGlobalControl.GetMachineCode());

            // 设置授权码后VIP功能才会生效,授权码由VIP工具生成
            FBroSharpVIPGlobalControl.SetAuthorizationCode("9CDA228F24B4D47F1C1126733CB57B36");

            Console.WriteLine(FBroSharpVIPGlobalControl.GetRegistrationVersion());

            FBroSharpInitSet set = new FBroSharpInitSet
            {
                //设置缓存目录
                cache_path = Directory.GetCurrentDirectory() + "\\Cache\\CachePath\\",

                //设置用户目录
                user_data_path = Directory.GetCurrentDirectory() + "\\Cache\\UserPath\\",

                //设置根缓存目录，必须是上面缓存目录的父目录，否则采用独立缓存可能会失效
                root_cache_path = Directory.GetCurrentDirectory() + "\\Cache\\",

                //启用事件消息循环
                multi_threaded_message_loop = true,

                //设置执行子进程，不设置他会默认以当前进程作为子进程
                browser_subprocess_path = Directory.GetCurrentDirectory() + "\\FBroSubprocess.exe",

                //本地化语言
                locale = "zh-CN",

                log_severity = FBroSharpLogSeverity.DISABLE
        };

            //创建初始化事件
            InitEvent init_event = new InitEvent();

            //执行初始化
            if (!FBroSharpInitControl.InitPro(set, init_event))
                return;


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            //FBroSharpInitControl.ClearWorkingAndV8Memory();

            //结束关闭释放框架
            FBroSharpInitControl.Shutdown(false);

            //Thread.Sleep(1000);
        }
    }
}
